<template>
	<view class="container">
		<Header>
			委员风采
		</Header>
		<scroll-view class="viewer" scroll-y="true" @scrolltolower="lowerBottom">
			<uni-list>
				<uni-list-item direction="row" v-for="item in data" :key="item.id" :to="`/pages/memberHome/memberDemeanourDetail?id=${item.id}`">
					<template v-slot:header>
						<view class="uni-thumb" v-if="item.image">
							<image :src="item.image" mode="aspectFill" style="width: 100%;height: 100%;"></image>
						</view>
					</template>
					<template v-slot:body>
						<view class="uni-list-box uni-content">
							<view class="title uni-ellipsis-2">
								{{item.title}}
							</view>
							<view class="date">
								{{item.createtime}}
							</view>
						</view>
					</template>
				</uni-list-item>
			</uni-list>
			<uni-load-more v-if="showLoad" :status="loadStatus" />
			<image src="https://zhzx.on-line-demo.com/image/zwsj.png" mode="aspectFit" class="no-data"
				v-if="loadStatus == 'no-more' && data.length == 0"></image>
		</scroll-view>
	</view>
</template>

<script>
	import Header from '../../components/header.vue'
	import request from '../../common/request.js'
	export default {
		components: {
			Header
		},
		data() {
			return {
				data:[],
				page: 1,
				loadStatus: 'loading',
				showLoad: false,
			}
		},
		mounted(){
			this.getListData()
		},
		methods: {
			lowerBottom(){
				if(this.loadStatus != 'loading'){
					this.loadStatus = 'loading'
					this.showLoad = true
					this.page++
					this.getListData()
				}
			},
			getListData(){
				request({
					url:'/member/learnStyle',
					data:{
						page: this.page,
						type_num: 1,  
					},
					method:'POST',
				}).then(res => {
						if(res.code == 1){
							this.data = this.data.concat(res.data)
							if(this.page == res.lastPage){
								this.loadStatus = 'no-more'
							}else{
								this.loadStatus = 'more'
								this.showLoad = false
							}
						}else{
							this.loadStatus = 'no-more'
						}
					})
			},
		}
	}
</script>

<style scoped>
	.container {
		background-color: #f2f2f2;
		height: 100vh;
	}
	.viewer{
		height: calc(100% - 55px - var(--status-bar-height));
		width: calc(100% - 16px);
		background-color: #fff;
		margin: 10px 8px;
		border-radius: 15px;
		overflow: hidden;
		padding: 15px;
		box-sizing: border-box;
	}
</style>